package com.cloud.async.util;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.BiConsumer;
import java.util.function.Supplier;

public class BusinessFutureUtils {

    private Executor executor;

    public <T> void test(Supplier<T> task, List<String> list) {
//        CompletableFuture<Object> result = CompletableFuture.supplyAsync(task::get, executor);
//        result.whenComplete((a,throwable)-> {
//
//        })
    }


    public static void main(String[] args) {
        CompletableFuture<Long> f = CompletableFuture.supplyAsync(() -> {
            System.out.println("supplyAsync.....");
            return 1 / 0L;
        });


        //BiConsumer


        System.out.println("main");
        CompletableFuture<Long> exceptionally = f.whenComplete((t, u) -> {
            System.out.println("t:" + t);
            System.out.println("u:" + u);
        }).whenComplete((w, e) -> {

        }).exceptionally((e) -> {
            System.out.println("e:" + e.getMessage());
            return 888L;
        });
        System.out.println(exceptionally);

        System.out.println("main1");

    }

}
